<?php

namespace App\Orchid\Layouts\Page;

use Orchid\Screen\Field;
use Orchid\Screen\Fields\Input;
use Orchid\Screen\Fields\Select;
use Orchid\Screen\Layouts\Rows;

class PageFiltersLayout extends Rows
{
    /**
     * Used to create the title of a group of form elements.
     *
     * @var string|null
     */
    protected $title = '筛选器';

    /**
     * Get the fields elements to be displayed.
     *
     * @return Field[]
     */
    protected function fields(): iterable
    {
        return [
            Input::make('filter[title]')
                ->type('text')
                ->value($this->query->get('filter.title'))
                ->placeholder('按页面标题搜索')
                ->title('页面标题'),

            Input::make('filter[slug]')
                ->type('text')
                ->value($this->query->get('filter.slug'))
                ->placeholder('按Slug搜索')
                ->title('Slug'),

            Select::make('filter[status]')
                ->options([
                    '' => '所有状态',
                    'draft' => '草稿',
                    'published' => '已发布',
                ])
                ->value($this->query->get('filter.status'))
                ->title('状态'),

            Input::make('filter[template]')
                ->type('text')
                ->value($this->query->get('filter.template'))
                ->placeholder('按模板搜索')
                ->title('模板'),
        ];
    }
}